package com.tbsoft.ehr.service.staffTransfer;

import java.util.List;

import com.tbsoft.ehr.constants.AssignStatus;
import com.tbsoft.ehr.dao.staffFile.StaffFileDao;
import com.tbsoft.ehr.dao.staffTransfer.TransferDao;
import com.tbsoft.ehr.model.ServiceCustomer;
import com.tbsoft.ehr.model.StaffInfo;
import com.tbsoft.ehr.model.TransferInfo;

public class TransferServiceImpl implements TransferService {

	private TransferDao transferDao;
	private StaffFileDao staffFileDao;
	
	public TransferDao getTransferDao() {
		return transferDao;
	}

	public void setTransferDao(TransferDao transferDao) {
		this.transferDao = transferDao;
	}

	public StaffFileDao getStaffFileDao() {
		return staffFileDao;
	}

	public void setStaffFileDao(StaffFileDao staffFileDao) {
		this.staffFileDao = staffFileDao;
	}

	@Override
	public void addTransferInfo(TransferInfo info) {
		this.transferDao.save(info);
		//入场：修改档案信息中的服务客户，出场：档案中服务客户设为空
		if(AssignStatus.ASSIGN_IN.name().equals(info.getTransferType())) {
			this.staffFileDao.changeServiceCustomer(info.getStaff().getStaffId(), info.getSc());
		} else {
			this.staffFileDao.changeServiceCustomer(info.getStaff().getStaffId(), new ServiceCustomer());
		}		
	}

	@Override
	public TransferInfo getTransferById(String id) {
		return this.transferDao.getTransferById(id);
	}

	@Override
	public List<TransferInfo> getTransfersByStaffId(String staffId) {
		return this.transferDao.getTransfersByStaffId(staffId);
	}

	@Override
	public int getTransferCount(TransferInfo info,List<StaffInfo> staffLst, String transferDateFrom,String transferDateTo) {
		return this.transferDao.getTransferCount(info,staffLst,transferDateFrom,transferDateTo);
	}

	@Override
	public List<TransferInfo> getTransfersByCondton(TransferInfo info,
			List<StaffInfo> staffLst, String transferDateFrom,
			String transferDateTo, int startIndex, int count) {
		return this.transferDao.getTransfersByCondton(info, staffLst, transferDateFrom, transferDateTo, startIndex, count);
	}

}
